<?php
session_start(); 
if(!isset($_SESSION['userName'])){
header( 'location:../index.php' ); 
} 
	include("../conf/connect.php");
	$user_id = $_SESSION['user_id'];
	$hhid= $_SESSION['usrHHid'];
	$resp_id = $_GET['resp_id'];
	$search_id=$_GET['search_id'];
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<title></title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<link rel="stylesheet" type="text/css" href="../style.css" media="screen" />
	<link rel="shortcut icon" href="images/favicon.ico" />
</head>
<body class="iub_back">
		<?php if($search_id==1){?>
		<table align="center" class="table_border">
			<tr>
					<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
			</tr>
			<tr>
					<td valign="top">Employment :  <a href="index.php" class="input-box" > &nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp; </a></td>
			</tr>
			<tr>
					<td> Answer(s) :</td>
			</tr>
			<?php
				$sql ="SELECT * FROM adult_question where hid='$hhid' and resp_id=$resp_id";
				$result=mysql_query( $sql);
				while($row = mysql_fetch_array($result)){
				echo $row['emp03'];
			?>
			<tr>
				<td>
					EMP01&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp01'];
						
						$hello="SELECT * FROM retreive_data where qus='emp01' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP02&nbsp;:&nbsp;&nbsp;
					<?php 
						echo $data=$row['emp02'];
						
						$hello="SELECT * FROM retreive_data where qus='emp01' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr <?php if($row['emp03']=='00'){ ?> style="display:none"<?php }?>>
				<td>
					EMP03&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp03'];
						
						$hello="SELECT * FROM retreive_data where qus='q7' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP04a&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp04_a'];
						
						$hello="SELECT * FROM retreive_data where qus='q7' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP04b&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp04_b'];
						
						$hello="SELECT * FROM retreive_data where qus='q7' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP05&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp05'];
						
						$hello="SELECT * FROM retreive_data where qus='q7' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP06&nbsp;:&nbsp;&nbsp;
					<?php 
						$data=$row['emp06'];
						
						$hello="SELECT * FROM retreive_data where qus='q7' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<tr>
				<td>
					EMP07&nbsp;:&nbsp;&nbsp;
					<?php 
						echo $data=$row['emp07'];
						
					?>  TK.
				</td>
			</tr>
			<?php } ?>
			<tr>
					<td align="right"><a href="index2.php" class="input-box"> &nbsp;&nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp; </a></td>
			</tr>
		</table>
		<?php } ?>
		<?php if($search_id==2){ ?>
		<table align="center" class="table_border">
			<tr>
					<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
			</tr>
			<tr>
					<td valign="top">Smoking/Chewing Pan :  <a href="index.php" class="input-box" > &nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp; </a></td>
			</tr>
			<tr>
					<td> Answer(s) :</td>
			</tr>
			<?php
				$sql ="SELECT * FROM adult_question where hid='$hhid' and resp_id=$resp_id";
				$result=mysql_query( $sql);
				while($row = mysql_fetch_array($result)){
				
			?>
			<?php if($row[spn01_a]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>A&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._a;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>A&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._a;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php }?> 
			<?php if($row[spn01_b]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>B&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._b;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_b"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>B&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._b;
						echo $data=$row["$qus"];						
					?> 
				</td>
			</tr>
			<?php } }?> 
			<?php if($row[spn01_c]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>C&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._c;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_c"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>C&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._c;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } }?>
			<?php if($row[spn01_d]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>D&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._d;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_d"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>D&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._d;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } }?>  
			<?php if($row[spn01_e]=='3'){$loop=1;}else {$loop=2;}
								 for($i=1;$i<=$loop;$i++){ ?>
			<tr>
				<td>
					SPN0<?php echo $i;?>E&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._e;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }
			if($row["spn01_e"]=='1'){
				for($i=3;$i<7;$i++){
			?>
			
			<tr>
				<td>
					SPN0<?php echo $i;?>E&nbsp;:&nbsp;&nbsp;
					<?php 
						$qus=spn0.$i._e;
						echo $data=$row["$qus"];
						
						
					?> 
				</td>
			</tr>
			<?php } } }?></table>
		<?php }?>
		<?php if($search_id==3){?>
		<table align="center" class="table_border">
			<tr>
					<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
			</tr>
			<tr>
					<td valign="top">General Health :  <a href="index.php" class="input-box" > &nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp; </a></td>
			</tr>
			<tr>
					<td> Answer(s) :</td>
			</tr>
			<?php
				$sql ="SELECT * FROM adult_question where hid='$hhid' and resp_id=$resp_id";
				$result=mysql_query( $sql);
				while($row = mysql_fetch_array($result)){
				
			?>
			<?php for($i=1;$i<=7;$i++){ ?>
			<?php if($i==3){?>
				<tr>
					<td>
						GH0<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
						<?php 
							 $qus=gh0.$i;
							 echo $data=$row["$qus"]; 
						?> 
					</td>
				</tr>
			<?php }else {?>
			<tr>
				<td>
					GH0<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
					<?php 
						 $qus=gh0.$i;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='$qus' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php } }?>
			<?php for($i=1;$i<=9;$i++){ ?>
			<tr>
				<td>
					GH0<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
					<?php 
						 $qus=gh08_a_.$i;
						 $data=$row["$qus"];
						
						$hello="SELECT * FROM retreive_data where qus='h24' and hoption='$data'";
						$end=mysql_query($hello);
						while($value=mysql_fetch_array($end)){
							echo $value['value'];;
						} 
					?> 
				</td>
			</tr>
			<?php }?>
			<?php }?>
			</table>
			<?php }?>  
			
			<?php if($search_id==4){?>
				<table align="center" class="table_border">
					<tr>
							<td class="header"><b class="htext">IUB Survey :: </b><br /><hr /> </td>
					</tr>
					<tr>
							<td valign="top">CHRONIC MORBILITY :  <a href="index.php" class="input-box" > &nbsp;&nbsp;Home&nbsp;&nbsp;&nbsp; </a></td>
					</tr>
					<tr>
							<td> Answer(s) :</td>
					</tr>
					<?php
						$sql ="SELECT * FROM chronic where hid='$hhid' and resp_id=$resp_id";
						$result=mysql_query( $sql);
						while($row = mysql_fetch_array($result)){
						
					?>
					<?php for($i=1;$i<+22;$i++){ ?>
						<tr>
							<td>
								CM01a1_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm01a1_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM01a2_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm01a2_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM02a_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm02a_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM03a_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm03a_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM04a_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm04a_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM05a_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm05a_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> 
							</td>
						</tr>
						<tr>
							<td>
								CM06a_<?php echo $i;?>&nbsp;:&nbsp;&nbsp;
								<?php 
									 $qus=cm06a_.$i;
									 $data=$row["$qus"];
									
									$hello="SELECT * FROM retreive_data where qus='spn01_a' and hoption='$data'";
									$end=mysql_query($hello);
									while($value=mysql_fetch_array($end)){
										echo $value['value'];
									}
								?> <br /><br />
							</td>
						</tr>
					<?php  } } }?>  
			
		</table>
		
		
		
</body>
</html>